function [v_Bomber, explosionTime, tdropOut ] = dropBomb( v_Ship, nrOfswitch, tdropIn ,n,last,steps, lag,pBomber)
%DROPBOMB : calculates the time when and where the bomb is dropped and when it
%explodes. The place of the bomb is defined by the vector v_Bomber

explosionTime=-1;
tdropOut=tdropIn;
v_Bomber=v_Ship;

%If ship does not alternate between A and B there is a restart; tdrop is
%again calculated
if(nrOfswitch==0)
   tdropOut=calcBomberTime(pBomber,n)   ;
end

%Bomb is dropped:
if(nrOfswitch==tdropOut)
   a=rand(1);
   if(a<1/(n^2+1)) %Bomb is dropped on current position
      v_Bomber=v_Ship ;
   else                % Bomb is dropped on one of the (n)^2 points
       for i=1:lag
            r=n*rand(1);                %choose a number between '0' and 'n'
            r=ceil(r)  ;                %r becomes integer: 1, 2, ..., n
            vari=last+r;
            vari=mod(vari,n+1);
            if isempty(v_Bomber)
                [v_Bomber, last] =moveahead(v_Bomber, vari);
            else
               if v_Bomber(end)==vari
                [v_Bomber, last] =moveback(v_Bomber);
                else 
                [v_Bomber, last] =moveahead(v_Bomber, vari);
               end
            end 
       end
       
   end
   explosionTime=steps+lag;
end

end

